package com.k.ums.handler;

import com.k.ums.model.RemoveCacheTask;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Description:
 * @Author: kt
 * @CreateTime: 2022/2/18
 */
public class RemoveCacheHandler {
    private BlockingQueue<Runnable> queue;
    private ThreadPoolExecutor tpe;
    private static RemoveCacheHandler instance = new RemoveCacheHandler();

    private RemoveCacheHandler() {
        queue = new ArrayBlockingQueue<>(1024);
        tpe = new ThreadPoolExecutor(
                4, 8, 10, TimeUnit.SECONDS, queue);
    }

    public static RemoveCacheHandler getInstance() {
        return instance;
    }

    public void execute(RemoveCacheTask task) {
        tpe.execute(task);
    }
}
